package Scuttlebutt;

import java.awt.event.*;
import javax.swing.*;
import java.awt.Component;
import java.lang.Runnable;

public class MyPanels extends JSplitPane 
{

	class TreeScrollPane extends JScrollPane implements Runnable{
		Scuttlebutt parent = null;
		Thread thisThread = null;
		public TreeScrollPane(Scuttlebutt parent){
			this.parent = parent;
			thisThread = new Thread(this);
			thisThread.start();
		}
		
		public void run(){
			FileTransferTable ftf = new FileTransferTable(parent);
			getViewport().setView(ftf);
		}
	}
	
	class TopPane extends JSplitPane {
		public TopPane(Scuttlebutt parent){
			setOrientation(JSplitPane.HORIZONTAL_SPLIT);
			setLeftComponent(new JScrollPane(parent.getProject().tree));
			setRightComponent(new EditPane(parent));
			setDividerLocation(parent.getSettings().getDivider());
		}
		
		public EditPane getEditPane(){
			return (EditPane)getRightComponent();
		}
	}
	
	
	
	public MyPanels(Scuttlebutt parent)
	{
		setOrientation(JSplitPane.VERTICAL_SPLIT);
		setLeftComponent(new TopPane(parent));
		setRightComponent(new JScrollPane(new FileTransferTable(parent)));
		setDividerLocation(parent.getSettings().getLowerDivider());
	}
	
	public int getTopDivider(){
		return ((TopPane)getLeftComponent()).getDividerLocation();
	}
	
	public int getBottomDivider(){
		return getDividerLocation();
	}
	
	public EditPane getEditPane(){
		return ((TopPane)getLeftComponent()).getEditPane();
	}
	
	public FileTransferTable getFileTransferTable(){
		return (FileTransferTable)((JScrollPane)getBottomComponent()).getViewport().getView();
	}

}

